package org.stvd.repository.oauth.impl;

import java.util.List;

import org.springframework.stereotype.Repository;
import org.stvd.core.dto.QueryResult;
import org.stvd.entities.oauth.OauthClientDetails;
import org.stvd.repository.base.impl.BaseDaoImpl;
import org.stvd.repository.oauth.OauthClientDetailsDao;

/**
 * Oauth客户端Repository实现类
 * @author houzx
 */
@Repository("OauthClientDetailsDao")
public class OauthClientDetailsDaoImpl extends BaseDaoImpl<OauthClientDetails> 
    implements OauthClientDetailsDao{

    @Override
    public QueryResult<OauthClientDetails> queryOauthClientResult(int start, int limit, String clientId, String clientName){
        String hql = "FROM OauthClientDetails WHERE 1 = 1"
            + " AND (clientId = ?0 OR '' = ?0) "
            + " AND (clientName like ?1)"
            + " ORDER BY createTime";
        return getQueryResultByHQL(start, limit, hql, clientId, "%"+clientName+"%");
    }

    @Override
    public List<OauthClientDetails> listOauthClientByClientId(String clientId) {
        return findByHQL("FROM OauthClientDetails WHERE clientId = ?0", clientId);
    }


}
